import { pubRequire, downFile } from '@utils/public'

const baseUrl = '/user-group'

// 用户分组规则
export function userGroupRules(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/portraits`, Object.assign({ ifEnable: 1 }, params) , callBack, errBack)
}

// 查询分组列表
export function userGroupList(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}`, params, callBack, errBack)
}

// 启用分组
export function enabled(id, obj, callbBack, errBack) {
  return pubRequire('put',`${baseUrl}/start/${id}`, obj, callbBack, errBack)
}

// 禁用分组
export function disabled(id, obj, callbBack, errBack) {
  return pubRequire('put',`${baseUrl}/end/${id}`, obj, callbBack, errBack)
}

// 校验分组名是否重复
export function checkGroupName(params, callBack, errBack) {
  return pubRequire('get', `${baseUrl}/verifications`, params, callBack, errBack)
}

// 新增分组
export function appendUserGroup(params, callBack, errBack) {
  return pubRequire('post', `${baseUrl}`, params, callBack, errBack)
}

// 按照id查询分组
export function userGroupDetails(id, callbBack, errBack) {
  return pubRequire('get', `${baseUrl}/${id}`, {}, callbBack, errBack)
}

// 编辑分组
export function editUserGroup(id, obj, callbBack, errBack) {
  return pubRequire('put',`${baseUrl}/${id}`, obj, callbBack, errBack)
}

// 下载dp号模板
export function downUrl() {
  return `/activities/prize/download/dp-account`
}

// 下载导入失败大鹏用户信息
export function downDpAccountErrorDoc() {
  return downFile('get', `${baseUrl}/export/dp-account/error?userGroup=true`, {}, '上传失败信息')
}

// 按照id导出用户分组的大鹏号
export function dpaccount(id) {
  return `/user-group/export/group/dpaccount/${id}`
}